package com.example.first

import android.os.Bundle
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import com.example.first.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    private lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        val linearLayout= LinearLayout(this)
        linearLayout.orientation = LinearLayout.VERTICAL
        binding = ActivityMainBinding.inflate(layoutInflater)


        val imageView = ImageView(this)
        imageView.layoutParams = ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT
        )
        imageView.setImageResource(R.drawable.flag)
        linearLayout.addView(imageView)


        val textView = TextView(this)
        textView.layoutParams = ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
        textView.textSize = 30F
        textView.text=getString(R.string.textView)
        linearLayout.addView(textView)

        val button = Button(this)
        button.width = ViewGroup.LayoutParams.MATCH_PARENT
        button.height = ViewGroup.LayoutParams.WRAP_CONTENT
        button.text =getString(R.string.button)
        linearLayout.addView(button)

        button.setOnClickListener(){
            textView.text=resources.getString(R.string.clicked)
        }
        setContentView(linearLayout)


    }
}